package com.myself.common.define.config;

import com.myself.common.define.util.CustomJwtUtil;
import jakarta.annotation.PostConstruct;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Component;


/**
 * @author 瑟瑟发抖
 */
@Data
@Component
@ConfigurationProperties(prefix = "jwt")
@EnableConfigurationProperties(JwtConfig.class)
public class JwtConfig {

    AccessTokenProperties accessToken = new AccessTokenProperties();
    RefreshTokenProperties refreshToken = new RefreshTokenProperties();

    @Data
    public class AccessTokenProperties {

        String securityKey;

        Long expiryHours;

    }

    @Data
    public class RefreshTokenProperties {

        String securityKey;

        Long expiryHours;

    }

    //    对工具类进行初始化
    @PostConstruct
    public void setUtilValue() {
        CustomJwtUtil.jwtConfigProperties = this;
    }


}
